package treazy.ultimate.stats;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class NewTeamActivity extends Activity {
	private Button create;
	private Button cancel;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
//		ActionBar actionBar = getActionBar();
//	    actionBar.setDisplayHomeAsUpEnabled(true);
	    
		setContentView(R.layout.newteam);
		
		create = (Button) findViewById(R.id.createTeamButton);
		
		create.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v){
				DatabaseHandler db = new DatabaseHandler(NewTeamActivity.this);
		        
				EditText teamName = (EditText) findViewById(R.id.teamName);
				db.addTeam(new Team(teamName.getText().toString()));
				Intent i = new Intent(getApplicationContext(), TeamActivity.class);
				i.putExtra("TeamName",teamName.getText().toString());
				startActivity(i);
				
			}
		});
		
		cancel = (Button) findViewById(R.id.cancelnewteam);
		
		cancel.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v){
				Intent i = new Intent(getApplicationContext(), ViewTeamsActivity.class);
				startActivity(i);
				
			}
		});

	}
}
